<%@ page import="java.io.File" %><%--
  Created by IntelliJ IDEA.
  User: cza20
  Date: 2021/4/11
  Time: 12:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>系统维护</title>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/css/web.css"/>
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/img/logo2.png" type="image/x-icon">
</head>
<body>
<%
    Object message = request.getAttribute("message");
    if (message != null && message!=""){
%>
<script type="text/javascript">
    alert("<%=message%>")
</script>
<%}%>
<jsp:include page="index.html"/>
<jsp:include page="WEB-INF/header/header-admin.jsp"/>
<label class="control-label">备份数据</label>
<br>
<div>
当前时间:
<span id="cg">2021/03/21 12:00:00</span>
<script>
    setInterval("cg.innerHTML=new Date().toLocaleString()",1000);
</script>
    <button   onclick="backup()" class="btn btn-primary btn-group-sm" >备份当前数据 </button>&nbsp;&nbsp;
</div>

<br>
<script type="text/javascript">
    function dateFormat(fmt, date) {
        let ret;
        const opt = {
            "Y+": date.getFullYear().toString(),        // 年
            "m+": (date.getMonth() + 1).toString(),     // 月
            "d+": date.getDate().toString(),            // 日
            "H+": date.getHours().toString(),           // 时
            "M+": date.getMinutes().toString(),         // 分
            "S+": date.getSeconds().toString()          // 秒
            // 有其他格式化字符需求可以继续添加，必须转化成字符串
        };
        for (let k in opt) {
            ret = new RegExp("(" + k + ")").exec(fmt);
            if (ret) {
                fmt = fmt.replace(ret[1], (ret[1].length == 1) ? (opt[k]) : (opt[k].padStart(ret[1].length, "0")))
            };
        };
        return fmt;
    }
    function backup() {
        let date = new Date();
        window.alert("备份时间："+dateFormat("YYYY-mm-dd HH:MM", date));
        window.location="BackupServlet"

    }
</script>
<label class="control-label">恢复数据</label>
<form action="RecoverServlet" method="post">
   <div class="form"style="margin-top: 10px; float:left">
    <div class="input-group">
                        <span class="input-group-addon">
                            <span class="glyphicon glyphicon-time"></span>
                        </span>
        <select  class="form-control" id="recover" name="sql" size="1" style="background-color: white" required="选择数据">
            <option selected></option>
            <%  File dir=new File(System.getProperty("user.dir")+"\\Backup\\");
                String[] fileNames=dir.list();
                for(int i=0;i<fileNames.length;i++){%>
            <option value="<%=fileNames[i]%>"><%=fileNames[i]%></option>
            <%}%>
        </select>
    </div>
   </div>
        <div class="form-group" style="margin-top: 10px; float:left">
            <input class="form-control btn btn-primary" name="submit" type="submit" value="恢复"/>
        </div>
</form>
</body>
</html>
